<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="id" />
        <el-table-column prop="createUserId" label="创建人 用户申请为0 后台创建为操作人ID" />
        <el-table-column prop="isDeleted" label="是否删除" />
        <el-table-column prop="createTime" label="创建日期" />
        <el-table-column prop="lastUpdateTime" label="最后更改时间" />
        <el-table-column prop="lastUpdateId" label="最后修改人 后台用户ID" />
        <el-table-column prop="insuredUserId" label="案件申请人ID" />
        <el-table-column prop="companyId" label="案件所属公司ID" />
        <el-table-column prop="companySiteId" label="案件所属公司站点ID" />
        <el-table-column prop="siteUserName" label="站长姓名" />
        <el-table-column prop="siteUserMobile" label="站长手机" />
        <el-table-column prop="reportNo" label="报案号" />
        <el-table-column prop="policyNo" label="保单号" />
        <el-table-column prop="userName" label="骑手名称" />
        <el-table-column prop="userMobile" label="出险人手机号码" />
        <el-table-column prop="userIdCard" label="骑手身份证" />
        <el-table-column prop="claimType" label="理赔对象，1骑手,2公司,3三者" />
        <el-table-column prop="responsibilityIds" label="责任判断ids" />
        <el-table-column prop="additional" label="有无附加险" />
        <el-table-column prop="caseSpeek" label="案件进度" />
        <el-table-column prop="accidentDate" label="事故发生时间" />
        <el-table-column prop="accidentTypeIds" label="出险类型" />
        <el-table-column prop="accidentRegionCode" label="事故区域code" />
        <el-table-column prop="accidentAddress" label="事故地址" />
        <el-table-column prop="accidentDesc" label="事故说明" />
        <el-table-column prop="responsibleUserId" label="理赔员ID，后台用户ID" />
        <el-table-column prop="caseStatus" label="案件状态" />
        <el-table-column prop="mainInsuredCompensationAmount" label="主险赔付金额" />
        <el-table-column prop="additionalMainInsuredCompensationAmount" label="附加险赔付金额" />
        <el-table-column prop="otherAmount" label="其他金额" />
        <el-table-column v-if="checkPer(['admin','insuredApply:edit','insuredApply:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudInsuredApply from '@/api/insuredApply'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, createUserId: null, isDeleted: null, createTime: null, lastUpdateTime: null, lastUpdateId: null, insuredUserId: null, companyId: null, companySiteId: null, siteUserName: null, siteUserMobile: null, reportNo: null, policyNo: null, userName: null, userMobile: null, userIdCard: null, claimType: null, responsibilityIds: null, additional: null, caseSpeek: null, accidentDate: null, accidentTypeIds: null, accidentRegionCode: null, accidentAddress: null, accidentDesc: null, responsibleUserId: null, caseStatus: null, mainInsuredCompensationAmount: null, additionalMainInsuredCompensationAmount: null, otherAmount: null }
export default {
  name: 'InsuredApply',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'InsuranceCaseController', url: 'api/insuredApply', idField: 'id', sort: 'id,desc', crudMethod: { ...crudInsuredApply }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'insuredApply:add'],
        edit: ['admin', 'insuredApply:edit'],
        del: ['admin', 'insuredApply:del']
      },
      rules: {
        insuredUserId: [
          { required: true, message: '案件申请人ID不能为空', trigger: 'blur' }
        ],
        companySiteId: [
          { required: true, message: '案件所属公司站点ID不能为空', trigger: 'blur' }
        ],
        siteUserName: [
          { required: true, message: '站长姓名不能为空', trigger: 'blur' }
        ],
        siteUserMobile: [
          { required: true, message: '站长手机不能为空', trigger: 'blur' }
        ],
        userName: [
          { required: true, message: '骑手名称不能为空', trigger: 'blur' }
        ],
        userMobile: [
          { required: true, message: '出险人手机号码不能为空', trigger: 'blur' }
        ],
        userIdCard: [
          { required: true, message: '骑手身份证不能为空', trigger: 'blur' }
        ],
        claimType: [
          { required: true, message: '理赔对象，1骑手,2公司,3三者不能为空', trigger: 'blur' }
        ],
        responsibilityIds: [
          { required: true, message: '责任判断ids不能为空', trigger: 'blur' }
        ],
        additional: [
          { required: true, message: '有无附加险不能为空', trigger: 'blur' }
        ],
        accidentDate: [
          { required: true, message: '事故发生时间不能为空', trigger: 'blur' }
        ],
        caseStatus: [
          { required: true, message: '案件状态不能为空', trigger: 'blur' }
        ]
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
